package com.qf.bank.controller;


import com.qf.bank.entity.Account;
import com.qf.bank.response.R;
import com.qf.bank.service.IAccountService;
import com.qf.bank.utils.TokenUtils;
import com.qf.bank.vo.input.UpdatePasswordInputVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author author
 * @since 2022-12-03
 */
@RestController
@RequestMapping("/account")
public class AccountController {

    @Autowired
    private IAccountService accountService;

    @RequestMapping("/doLogin")
    public R doLogin(HttpServletRequest request, Account account) {
        return accountService.doLogin(request, account);
    }

    @RequestMapping("/logout")
    public R logout(HttpServletRequest request) {
        return accountService.logout(request);
    }

    @RequestMapping("/searchBalance")
    public R searchBalance(HttpServletRequest request) {
        String userId = TokenUtils.getUserId(request);

        return accountService.searchBalance(userId);
    }

    @RequestMapping("/updatePassword")
    public R updatePassword(HttpServletRequest request, UpdatePasswordInputVo inputVo) {
        return accountService.updatePassword(request, inputVo);
    }
}
